package com.example.knowledgeget1.KnowtCommon.Repository;

import com.example.knowledgeget1.KnowtCommon.Entity.Knowin;
import com.example.knowledgeget1.KnowtCommon.Entity.KnowinId;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface KnowinRepository extends JpaRepository<Knowin, KnowinId> {

    @Query("SELECT k.id.knowId FROM Knowin k WHERE k.id.courseId = ?1")
    List<Long> findKnowIdsByCourseId(Long courseId);

    // 根据knowId删除Knowin实体
    @Transactional
    void deleteById_KnowId(Long knowId);
}